import mysql.Mysql;

/**
 * Class User
 */
public class User {


	private int id;
	private String name;
	private String email;
	private String password;
	private int point;

	//
	// Constructors
	//
	public User(String name, String email, String password) {
		this.name = name;
		this.email = email;
		this.password = password;
		
	};

	//
	// Methods
	//

	//
	// Accessor methods
	//


	public void setId(int id) {
		this.id = id;
	}

	public int getId() {
		return this.id;		
	}

	public String getName() {
		return this.name;
	}

	public String getEmail() {
		return this.email;
	}

	public String getPassword() {
		return this.password;
	}

	public void addPoints(int points) {
		this.point += points;
	}

	public int getPoint() {
		return this.point;
	}

	public void save() {
		Mysql bd = new Mysql();
		String strsql;
		if (this.id > 0) {
			strsql = "update tb_users set name = '"+this.name+"', email='"+this.email
					+ "', password = '"+this.password+"' where id = " + this.id;
		} else {
			strsql = "insert into tb_users (name, email, password) "
					+ "values ('" + this.name + "', '"+this.email+"', '"+this.password+"');";			
		}
		bd.insertUpdate(strsql);
	}
}
